#include "App.h"
#include "State.h"
State::State()
{
	m_pFont = 0;
	D3DXCreateFont(g_pD3dDev , 175, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Chlorinar"), &m_pFont);
	if (!m_pFont)
	{
		D3DXCreateFont(g_pD3dDev , 275, 0, FW_BOLD, 0, TRUE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Chiller"), &m_pFont);
	}
	if (!m_pFont)
	{
		D3DXCreateFont(g_pD3dDev , 250, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Calibri"), &m_pFont);
	}
}
State::~State()
{
	ReleaseCOM(m_pFont);
}
void State::draw()
{
	HR
	(
		g_pD3dDev->Clear(0, 0, D3DCLEAR_TARGET,	D3DCOLOR_XRGB(0, 128, 128), 1.0f, 0)
	);
	RECT formatRect;
	GetClientRect(g_pApp->getWnd(), &formatRect);
	HR(g_pD3dDev->BeginScene());
	m_pFont->DrawText
	(
		0, L"Virtual city", -1,
		&formatRect, 
		DT_CENTER | DT_VCENTER,
		D3DCOLOR_XRGB(rand() % 256, rand() % 256, rand() % 256)
	);
	HR(g_pD3dDev->EndScene());
	HR(g_pD3dDev->Present(0, 0, 0, 0));
}
void State::update(float p_fDt)
{
	
}
void State::onLostDevice()
{
	m_pFont->OnLostDevice();
}
void State::onResetDevice()
{
	m_pFont->OnResetDevice();
}
